local InnerDataManagerFL = require("innerdata.InnerDataManagerFL")
local InnerDataDefine = require("innerdata.Define")
local Notify = require("activity.Notify")
local ActivityLogicL =require("activity.ActivityLogicL")
local ActivityDefine = require("activity.Define")
local DailyActFL = require("activity.DailyActFL")
local ChongzhiDraw = require("activity.operate.ChongzhiDraw")
local ChongzhiRebate = require("activity.operate.ChongzhiRebate")
local ChongzhiPresent = require("activity.operate.ChongzhiPresent")
local CritDraw = require("activity.operate.CritDraw")
local DaBiao = require("activity.operate.DaBiao")
local YYLimitBuy = require("activity.operate.LimitBuy")
local OperateActFL = require("activity.OperateActFL")
local ComplexSrvActFL = require("activity.ComplexSrvActFL")
local DateActFL = require("activity.DateActFL")
local DateActLogicL = require("activity.date.DateActLogicL")
local ActivityDouble = require("activity.operate.ActivityDouble")
local CopyFast = require("activity.operate.CopyFast")
local LvRank = require("activity.operate.LvRank")
local PataRank = require("activity.operate.PataRank")
local ActivityPlay = require("activity.operate.ActivityPlay")
local PayDraw = require("activity.operate.PayDraw")
local ComplexPayDraw = require("activity.complex.PayDraw")
local ComplexActivityPlay = require("activity.complex.ActivityPlay")
local ComplexCopyFast = require("activity.complex.CopyFast")
local DateLimitBuy = require("activity.date.LimitBuy")
local DateCritDraw = require("activity.date.CritDraw")
local ChongzhiDateRebate = require("activity.date.ChongzhiRebate")
local DatePayDraw = require("activity.date.PayDraw")
local DailyGift = require("activity.operate.DailyGift")
local DateChongzhiDraw = require("activity.date.ChongzhiDraw")

function CG_ACTIVITY_VALUE_CONF(human)
    Notify.CG_ACTIVITY_VALUE_CONF(human)
end
function CG_ACTIVITY_VALUE_UPDATE(human)
    Notify.CG_ACTIVITY_VALUE_UPDATE(human)
end

function CG_ACTIVITY_VALUE_REWARD(human, msg)
    Notify.CG_ACTIVITY_VALUE_REWARD(human, msg.value)
end
function CG_ACTIVITY_VALUE_FINISH(human, msg)
    ActivityLogicL.finishActValue(human, msg.id)
end
function CG_ACTIVITY_COPY_CONF(human)
    Notify.CG_ACTIVITY_COPY_CONF(human)
end
function CG_ACTIVITY_COPY_REWARD(human, msg)
    Notify.CG_ACTIVITY_COPY_REWARD(human, msg.copyID)
end
function CG_ACTIVITY_COPY_UPDATE(human)
    Notify.CG_ACTIVITY_COPY_UPDATE(human)
end



function  CG_ACTIVITY_ACT_CONF(human)
    Notify.CG_ACTIVITY_ACT_CONF(human)
end

function CG_ACTIVITY_STATUS_UPDATE(human)
    Notify.CG_ACTIVITY_STATUS_UPDATE(human)
end

function CG_ACTIVITY_COPY_ADD(human, msg)
    ActivityLogicL.addCopyEnterCnt(human, msg.copyID)
end




--开服活动start
--打开活动面板
function CG_OPEN_KAIFU_ACTIVITY(human, msg)

end
--领取奖励
function CG_KAIFU_ACT_GET_REWARD(human, msg)

end
--购买道具
function CG_KAIFU_ACT_BUY_ITEM(human, msg)

end
--开始抽奖
function CG_KAIFU_ACT_START_DRAW(human)

end
-- 开服活动 end

function W2LProcess(human, nType, nData)
    if nData.type == 1 then
        DailyActFL.onProcessActState(nData.data)
    elseif nData.type == 2 then
        OperateActFL.onProcessActState(nData.data)
    elseif nData.type == 3 then
        ComplexSrvActFL.onProcessActState(nData.data)
    elseif nData.type == 4 then
        DateActFL.onProcessActState(nData.data)
    elseif nData.type == 5 then
        DateActLogicL.onSendHolidayGift(human, nData.data)
    elseif nData.type == 6 then
        DateActLogicL.onSendHolidayGift(human, nData.data)
    elseif nData.type == 7 then
        DateActLogicL.onSendChongzhiXBackY(human, nData.data)
    end
end
--运营活动：领取奖励，购买道具
function CG_YUNYING_GET_REWARD(human, msg)
  if not OperateActFL.onCheckActIsRunning(msg.id) and msg.id ~= ActivityDefine.OPERATEACT_TYPE_LIMITBUY then
    return
  end
  if msg.id == ActivityDefine.OPERATEACT_TYPE_CHONGZHIREBATE then
    ChongzhiRebate.getReward(human, msg.id, msg.index)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_CHONGZHIDRAW then
    ChongzhiDraw.getReward(human, msg.id, msg.index)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_LIMITBUY then
    YYLimitBuy.getReward(human, msg.id, msg.index, msg.relateId)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_CHONGZHIRANK then
  elseif msg.id <= ActivityDefine.OPERATEACT_TYPE_EQUIPPOWER then
    DaBiao.getReward(human, msg.id, msg.index)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_QPOINT then
--    QPoint.getReward(human)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_CRITDRAW then
    CritDraw.getReward(human, msg.id, msg.index)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_COPYFAST then
    CopyFast.getReward(human, msg.id, msg.index)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_ACTIVITYPLAY then
    ActivityPlay.getReward(human, msg.id, msg.index)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_PATARANK then
    PataRank.getReward(human, msg.id, msg.index)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_LVRANK then
    LvRank.getReward(human, msg.id, msg.index)
  elseif msg.id <= ActivityDefine.OPERATEACT_TYPE_DUOBAODOUBLE then
    ActivityDouble.getReward(human, msg.id, msg.index)
  end
end
--运营活动：领取奖励，开始抽奖
function CG_YUNYING_START_DRAW(human, msg)
  if not OperateActFL.onCheckActIsRunning(msg.id) then
    return
  end
  if msg.id == ActivityDefine.OPERATEACT_TYPE_CHONGZHIDRAW then
    ChongzhiDraw.startDraw(human, msg.id)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_CRITDRAW then
    CritDraw.startDraw(human, msg.id)
  end
end
--运营活动：领取奖励，结束抽奖
function CG_YUNYING_END_DRAW(human, msg)
  if msg.id == ActivityDefine.OPERATEACT_TYPE_CHONGZHIDRAW then
    ChongzhiDraw.endDraw(human, msg.id)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_CRITDRAW then
    CritDraw.endDraw(human, msg.id)
  end
end
--运营活动：打开活动面板
function CG_OPEN_YUNYING_ACTIVITY(human, msg)
  local version = OperateActFL.onGetCurActVersion(msg.id)
  if version then
    human.db.YYActivityId[msg.id] = version
  end 
  if msg.id == ActivityDefine.OPERATEACT_TYPE_CHONGZHIREBATE then
    ChongzhiRebate.open(human, msg.id, msg.type)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_CHONGZHIDRAW then
    ChongzhiDraw.open(human, msg.id, msg.type)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_LIMITBUY then
    YYLimitBuy.open(human, msg.id, msg.type)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_CHONGZHIRANK then
  elseif msg.id >= ActivityDefine.OPERATEACT_TYPE_SHENBING and msg.id <= ActivityDefine.OPERATEACT_TYPE_EQUIPPOWER then
    DaBiao.open(human, msg.id, msg.type)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_QPOINT then
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_CRITDRAW then
    CritDraw.open(human, msg.id, msg.type)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_COPYFAST then
    CopyFast.open(human, msg.id, msg.type)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_ACTIVITYPLAY then
    ActivityPlay.open(human, msg.id, msg.type)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_PATARANK then
    PataRank.open(human, msg.id, msg.type)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_LVRANK then
    LvRank.open(human, msg.id, msg.type)
  elseif msg.id <= ActivityDefine.OPERATEACT_TYPE_DUOBAODOUBLE then
    ActivityDouble.open(human, msg.id, msg.type)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_PAYDRAW then
    PayDraw.open(human, msg.id, msg.type)
  end
end
--消费转盘
function CG_YUNYING_PAYDRAW_START(human, msg)
  PayDraw.startDraw(human, msg.times)
end
function CG_YUNYING_PAYDRAW_END(human)
  PayDraw.endDraw(human)
end
function CG_YUNYING_PAYDRAW_GET_REWARD(human, msg)
  PayDraw.getReward(human, msg.index)
end

function CG_CHONGZHI_PRESENT_QUERY(human)
	ChongzhiPresent.query(human)
end

function CG_CHONGZHI_PRESENT_GET(human)
	ChongzhiPresent.get(human)
end
--运营活动end

------------------------------------合服活动start-------------------------------------------------
--打开和服活动
function CG_OPEN_COMPLEX_ACTIVITY(human, msg)
  if msg.id == ActivityDefine.OPERATEACT_TYPE_ACTIVITYPLAY then
    ComplexActivityPlay.open(human, msg.id)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_PAYDRAW then
    ComplexPayDraw.open(human, msg.id)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_COPYFAST then
    ComplexCopyFast.open(human, msg.id)
  end
end
function CG_COMPLEX_PAYDRAW_START(human, msg)
  ComplexPayDraw.startDraw(human, msg.times)
end
function CG_COMPLEX_PAYDRAW_END(human, msg)
  ComplexPayDraw.endDraw(human)
end
--领取奖励
function CG_COMPLEX_GET_REWARD(human, msg)
  if msg.id == ActivityDefine.OPERATEACT_TYPE_ACTIVITYPLAY then
    ComplexActivityPlay.getReward(human, msg.id, msg.index)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_COPYFAST then
    ComplexCopyFast.getReward(human, msg.id, msg.index)
  end
end
function CG_COMPLEX_PAYDRAW_GET_REWARD(human,msg)
  ComplexPayDraw.getReward(human, msg.index)
end
------------------------------------------------合服活动end---------------------------------------
-----------------------------------------------定时活动start--------------------------------------
function CG_DATE_END_DRAW(human, msg)
  if msg.id == ActivityDefine.OPERATEACT_TYPE_CRITDRAW then
    DateCritDraw.endDraw(human)
  else    
  end
end
function CG_DATE_START_DRAW(human, msg)
  if msg.id == ActivityDefine.OPERATEACT_TYPE_CRITDRAW then 
    DateCritDraw.startDraw(human, msg.id)  
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_CHONGZHIDRAW then
    DateChongzhiDraw.startDraw(human, msg.id)
  end
end
function CG_DATE_PAYDRAW_START(human, msg)
  DatePayDraw.startDraw(human, msg.times)
end
function CG_OPEN_DATE_ACTIVITY(human, msg)
  local version = DateActFL.onGetCurActVersion(msg.id)
  if version then
    human.db.DateActivityId[msg.id] = version
  end

  if msg.id == ActivityDefine.OPERATEACT_TYPE_CHONGZHIREBATE then
    ChongzhiDateRebate.open(human, msg.id)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_CHONGZHIDRAW then
    DateChongzhiDraw.open(human, msg.id) 
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_LIMITBUY then
    DateLimitBuy.open(human, msg.id)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_CRITDRAW then
    DateCritDraw.open(human, msg.id)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_PAYDRAW then
    DatePayDraw.open(human, msg.id)
  end

end
function CG_DATE_GET_REWARD(human, msg)
  if msg.id == ActivityDefine.OPERATEACT_TYPE_CHONGZHIREBATE then
    ChongzhiDateRebate.getReward(human, msg.id, msg.index) 
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_LIMITBUY then
    DateLimitBuy.getReward(human, msg.id, msg.index)
  elseif msg.id == ActivityDefine.OPERATEACT_TYPE_PAYDRAW then
    DatePayDraw.getReward(human, msg.index)
  end
end

--每日豪礼
function CG_DAILY_GIFT_QUERY(human, msg)
  DailyGift.sendDailyGift(human)
end

function CG_DAILY_GIFT_GET(human, msg)
  DailyGift.getDailyGift(human)
end
---------------------------------------------定时活动end--------------------------------------
InnerDataManagerFL.Register(InnerDataDefine.INNERDATA_TYPE_ACT, W2LProcess)
